package dfs_bfs;

import java.util.*;

public class ngezi {
    public static void main(String[] args) {
        dfs_main();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<List<Integer>> adj = new ArrayList<>();
        int[] du = new int[n];
        for (int i = 0; i < n; i++) {
            adj.add(new ArrayList<>());
        }
        sc.nextLine();
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            if(s.equals("")){
                break;
            }
            String[] str = s.split(" ");
            adj.get(Integer.parseInt(str[0])).add(Integer.parseInt(str[1]));
            du[Integer.parseInt(str[1])]++;
        }

        Deque<Integer> deque = new LinkedList<>();
        for (int i = 0; i < du.length; i++) {
            if(du[i] == 0)
                deque.add(i);
        }
        while(!deque.isEmpty()){
            int i = deque.poll();
            n--;
            List<Integer> p = adj.get(i);
            for (int j = 0; j < p.size(); j++) {
                du[p.get(j)]--;
                if(du[p.get(j)] == 0)
                    deque.add(p.get(j));
            }
        }
        if(n == 0)
            System.out.println("yes");
        else
            System.out.println("no");
    }


    public static void dfs_main() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<List<Integer>> adj = new ArrayList<>();
        int[] du = new int[n];
        for (int i = 0; i < n; i++) {
            adj.add(new ArrayList<>());
        }
        sc.nextLine();
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            if(s.equals("")){
                break;
            }
            String[] str = s.split(" ");
            adj.get(Integer.parseInt(str[1])).add(Integer.parseInt(str[0]));
        }
        for (int i = 0; i < n; i++) {
            if(!dfs(i, adj, du)){
                System.out.println("no");
                return;
            }
        }
        System.out.println("yes");

    }
    public static boolean dfs(int i, List<List<Integer>> adj, int[] used){
        if(used[i] == 2)
            return false;
        if(used[i] == 1)
            return true;
        used[i] = 2;
        for (int j = 0; j < adj.get(i).size(); j++) {
            if(!dfs(adj.get(i).get(j), adj, used))
                return false;
        }
        used[i] = 1;
        return true;
    }
}

/*
5
4 3
0 4
2 1
3 2
 */